/*
 * @Description: 
 * @version: 
 * @Author: 171
 * @Date: 2022-09-05 11:28:49
 * @LastEditors: 171
 * @LastEditTime: 2022-09-22 17:55:13
 */

import { defineStore } from 'pinia'
import { NAMES } from './name-space'

export const useUserStore = defineStore(NAMES.USER, {
  state: () => ({
    token: localStorage.getItem('token') ?? "",
    userInfo: {
      id: localStorage.getItem('id') ?? "",
    }
  }),
  actions: {
    updateToken(){ 
      this.token = localStorage.getItem('token') ?? "";
    },
    updateUserInfo(){
      this.userInfo.id = localStorage.getItem('id') ?? "";
    }
  },
  getters: {
    status(): boolean{
      return this.token !== "";
    },
  }
})